package com.software.graduationproject.modules.order.web;

import com.baomidou.mybatisplus.core.metadata.Page;

import com.software.graduationproject.commons.select.Select;
import com.software.graduationproject.commons.util.Result;
import com.software.graduationproject.commons.util.Results;
import com.software.graduationproject.modules.order.entity.OrderInfo;
import com.software.graduationproject.modules.order.object.OrderInfoVo;
import com.software.graduationproject.modules.order.service.OrderInfoService;
import com.software.graduationproject.modules.order.object.OrderInfoCreateQo;
import com.software.graduationproject.modules.order.object.OrderInfoUpdateQo;

import com.v2coding.validate.CreateGroup;
import com.v2coding.validate.UpdateGroup;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * OrderInfoController : 订单表
 * ---------------------------------------------------------------------------------------------------------------------
 */
@Validated
@RestController
@RequestMapping("/Order/OrderInfo")
@Api(value = "API - 订单表", tags = {"订单表接口"})
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping("/create")
    @ApiOperation("新增订单表")
    public Result createQo(@RequestBody @Validated(CreateGroup.class) List<OrderInfoCreateQo> qos) {
        orderInfoService.createQo(qos);
        return Results.success();
    }
//
//    @PostMapping("/update")
//    @ApiOperation("修改订单表")
//    public Result updateQo(@RequestBody @Validated(UpdateGroup.class) OrderInfoUpdateQo qo) {
//        orderInfoService.updateQo(qo);
//        return Results.success();
//    }
//
//    @PostMapping("/delete")
//    @ApiOperation("删除订单表")
//    public Result delete(@RequestBody Long id) {
//        orderInfoService.delete(id);
//        return Results.success();
//    }
//
//    @PostMapping("/deleteList")
//    @ApiOperation("批量删除订单表")
//    public Result deleteList(@RequestBody Long []ids) {
//        orderInfoService.deleteList(ids);
//        return Results.success();
//    }
//
//    @GetMapping("/select")
//    @ApiOperation("查询订单表详情")
//    public Result<OrderInfoVo> selectVo(Long id) {
//        OrderInfoVo orderInfoVo = orderInfoService.selectVo(id);
//        return Results.success(orderInfoVo);
//    }

    @GetMapping("/selectList")
    @ApiOperation("查询订单表列表")
    @ApiImplicitParams({ //
            @ApiImplicitParam(name = "select", value = "查询条件", required = false, dataTypeClass = String.class, paramType = "query"),//
    })
    public Result<List<OrderInfoVo>> selectListVo(@ApiIgnore Select select) {
        List<OrderInfoVo> orderInfoVoList = orderInfoService.selectListVo(select);
        return Results.success(orderInfoVoList);
    }

    @GetMapping("/selectPage")
    @ApiOperation("查询订单表分页")
    @ApiImplicitParams({ //
            @ApiImplicitParam(name = "select", value = "查询条件", required = false, dataTypeClass = String.class, paramType = "query"),//
    })
    public Result<Page<OrderInfoVo>> selectPageVo(@ApiIgnore Select select) {
        Page<OrderInfoVo> orderInfoVoPage = orderInfoService.selectPageVo(select);
        return Results.success(orderInfoVoPage);
    }



}
